package com.tjakus.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.tjakus.logging.Logging;
import com.tjakus.properties.Property;

/**
 * This class represents quartz job which is responsible for reading properties
 * and reschedule quartz jobs if necessary.
 * 
 * @author tjakus
 * 
 */

public class JobReadProperty implements Job {

	/**
	 * This method executes quartz job which is responsible for reading property
	 * 
	 */
	public void execute(JobExecutionContext context) throws JobExecutionException {
		Logging.getLogger().info("JobReadProperty - execute - [ STARTED ]");
		// Read properties from DB
		Property.initializeProperties();
		// Reinitialize quartz jobs based on properties in DB
		QuartzUtil.initializeQuartzJobs();
		// Reschedule jobs if schedule has been changed
		QuartzUtil.rescheduleJobs();
		Logging.getLogger().info("JobReadProperty - execute - [ FINISHED ]");
	}
}
